/*
 * @Author: luoqi
 * @Date: 2021-05-26 16:10:33
 * @ Modified by: luoqi
 * @ Modified time: 2025-04-11 19:22
 */

#ifndef _QTERM_H
#define _QTERM_H

#include <bsp.h>
#include "qcli.h"

#ifndef QNULL
#define QNULL ((void *)0)
#endif

#define QSH(...)                bsp_printf(__VA_ARGS__)
#define ISARG(str1, str2)       (isarg(str1, str2) == 0)
#define ISARGV(n, str)          (isargv(argv[n], #str) == 0)
#define ISARGC(n)               (argc == n)

#define ARG_ERR(lable)          bsp_printf(" #! Arg error <%s>\r\n", lable)

#define PRINT_HEX(ptr, size)     do{                                                         \
    for(int i = 0; i < size; i++){                       \
        bsp_printf(" %02X", ptr[i]);                     \
    }                                                    \
    bsp_printf("\r\n");                                  \
} while(0)

int isarg(const char *s, const char *arg);

int qterm_init(void);

int qterm_exec(char c);

int qterm_call(char *args);

int qterm_attach(QCliCmd *cmd, const char *name, QCliCallback callback, const char *usage);

int qterm_detach(QCliCmd *cmd);

int qterm_help(QCliArgsEntry *table, uint32_t sz);

#endif
